function Account(balance, password) {
  this.balance = balance;
  this.password = password;
  this.wongTimes = 0;
}
const output = x => console.log(x);
Account.prototype.withdraw = function (amount, input) {
  return checkPassword.call(this, input, fn.bind(this), amount);

  function fn(amount) {
    if (this.balance >= amount) {
      this.balance -= amount;
      return output(this.balance);
    }
    return output('not enough money');
  }
};
Account.prototype.deposit = function (amount) {
  const self = this;
  self.balance += amount;
  return output(self.balance);
};

function checkPassword(input, fn, ...args) {
  if (this.wongTimes >= 6) return output('call the cops');
  if (input === this.password) {
    this.wongTimes = 0;
    return fn(...args);
  }
  this.wongTimes += 1;
  return output('wrong');
}

const acc = new Account(100, '123456');
acc.withdraw(100, '12345');
acc.withdraw(90, '123456');
acc.deposit(200);
